package shoppingmall.manage.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import shoppingmall.manage.dto.PageBean;
import shoppingmall.manage.dto.Result;
import shoppingmall.manage.service.impl.UserAddressServiceImpl;

/**
 * 控制层-提供平台会员用户收货地址表的相关服务
 */

@Slf4j  //记录日志
@RestController
public class UserAddressController {

        @Autowired(required = false)
        private UserAddressServiceImpl userAddressService;
        /**
         * 查询平台会员用户地址表的所有数据
         * @param user
         * @return
         */
        @GetMapping("/manage/user/address")
        public Result getAddressList () {
            log.info("查询所有平台会员收货地址表信息!");
            //调用服务层方法
            PageBean MemberAddressList = userAddressService.getAllMemberAddressList();
            if(MemberAddressList.getTotal() == 0){
                return Result.success("未查询到地址表中的信息!");
            }
            return Result.success(MemberAddressList);
        }
}
